/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.edinet.agencialinea3.ejb.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ivan
 */
@Entity
@Table(name = "EMISOR_DOCUMENTO")
@NamedQueries({
    @NamedQuery(name = "EmisorDocumento.findAll", query = "SELECT e FROM EmisorDocumento e"),
    @NamedQuery(name = "EmisorDocumento.findByRut", query = "SELECT e FROM EmisorDocumento e WHERE e.rut = :rut"),
    @NamedQuery(name = "EmisorDocumento.findByNombre", query = "SELECT e FROM EmisorDocumento e WHERE e.nombre = :nombre")})
public class EmisorDocumento implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "RUT")
    private BigDecimal rut;
    @Size(max = 50)
    @Column(name = "NOMBRE")
    private String nombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "emisorDocumento")
    private List<Documento> documentoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "emisorDocumento")
    private List<Declaracion> declaracionList;

    public EmisorDocumento() {
    }

    public EmisorDocumento(BigDecimal rut) {
        this.rut = rut;
    }

    public BigDecimal getRut() {
        return rut;
    }

    public void setRut(BigDecimal rut) {
        this.rut = rut;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public List<Documento> getDocumentoList() {
        return documentoList;
    }

    public void setDocumentoList(List<Documento> documentoList) {
        this.documentoList = documentoList;
    }

    public List<Declaracion> getDeclaracionList() {
        return declaracionList;
    }

    public void setDeclaracionList(List<Declaracion> declaracionList) {
        this.declaracionList = declaracionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rut != null ? rut.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EmisorDocumento)) {
            return false;
        }
        EmisorDocumento other = (EmisorDocumento) object;
        if ((this.rut == null && other.rut != null) || (this.rut != null && !this.rut.equals(other.rut))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.edinet.agencialinea3.ejb.entity.EmisorDocumento[ rut=" + rut + " ]";
    }
    
}
